Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: debug and compare modes fix #390

Merged
merged 6 commits into from
Dec 17, 2024
Merged

Conversation

dariaterekhova-actionengine
Copy link
Collaborator

No description provided.

Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-390.d3nof3l3x2sso4.amplifyapp.com

@@ -83,6 +81,8 @@ export const UploadPanel = ({
onFileUploaded,
onFileEvent,
}: UploadProps) => {
const UPLOAD_INPUT_ID = useMemo(() => `upload-file-input${crypto.randomUUID()}`, []);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this fix? It would be good to have a list of changes in the PR description with screenshots when applicable

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you have several upload panels open at the same time (for example in comparison mode) all actions go to the first one and you're unable to choose a file on the second one. This happens because all file inputs and divs that catch the actions have the same id. This fix generates the unique id for every upload panel so actions will be passed inside every upload panel separately

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand how randomUUID: () => "" can return something unique

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The stab needs to be there because jsdom doesn't have a stub for browser's crypto. And since we don't have tests where two upload panels would be shown at the same time, so randomUUID: () => "" is enough for all our tests.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we avoid hacks?
The offered approach is very weird:

  • We make a global variable that is bad practice;
  • We declare randomUUID that doesn't return a UUID;
  • Why crypto.reandomUUID? Is there any reason to mock nodejs API?

For example, we can use Redux to generate unique application-wide integer ids.

@@ -83,6 +81,8 @@ export const UploadPanel = ({
onFileUploaded,
onFileEvent,
}: UploadProps) => {
const UPLOAD_INPUT_ID = useMemo(() => `upload-file-input${crypto.randomUUID()}`, []);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we avoid hacks?
The offered approach is very weird:

  • We make a global variable that is bad practice;
  • We declare randomUUID that doesn't return a UUID;
  • Why crypto.reandomUUID? Is there any reason to mock nodejs API?

For example, we can use Redux to generate unique application-wide integer ids.

@dariaterekhova-actionengine dariaterekhova-actionengine dismissed belom88’s stale review December 17, 2024 12:27

I already moved the hack to test files, so chages requested needed to be done in another file

@dariaterekhova-actionengine dariaterekhova-actionengine removed the request for review from belom88 December 17, 2024 12:27
@dariaterekhova-actionengine dariaterekhova-actionengine merged commit 3403a56 into master Dec 17, 2024
3 checks passed
@dariaterekhova-actionengine dariaterekhova-actionengine deleted the dt/debug-fix branch December 17, 2024 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants